package com.java.module.user.controller.admin;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.java.common.lang.annotation.Log;
import com.java.common.lang.domain.AjaxResult;
import com.java.common.lang.enums.BusinessTypeEnum;
import com.java.common.utils.WebKit;
import com.java.module.user.domain.Invite;
import com.java.module.user.service.IInviteService;
import com.java.common.utils.poi.ExcelUtil;
import com.java.common.lang.domain.page.TableDataInfo;

/**
 * 用户邀请Controller
 * 
 * @author Administrator
 * @date 2025-07-08
 */
@RestController("AdminInviteController")
@RequestMapping("/user/invite")
public class InviteController {
    @Autowired
    private IInviteService inviteService;

    /**
     * 查询用户邀请列表
     */
    @PreAuthorize("@ss.hasPermi('user:invite:list')")
    @GetMapping("/list")
    public TableDataInfo list(Invite invite) {
        WebKit.startPage();
        List<Invite> list = inviteService.selectInviteList(invite);
        return WebKit.getDataTable(list);
    }

    /**
     * 导出用户邀请列表
     */
    @PreAuthorize("@ss.hasPermi('user:invite:export')")
    @Log(title = "用户邀请", businessType = BusinessTypeEnum.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Invite invite) {
        List<Invite> list = inviteService.selectInviteList(invite);
        ExcelUtil<Invite> util = new ExcelUtil<Invite>(Invite.class);
        return util.exportExcel(list, "invite");
    }

    /**
     * 获取用户邀请详细信息
     */
    @PreAuthorize("@ss.hasPermi('user:invite:query')")
    @GetMapping(value = "/{inviteId}")
    public AjaxResult getInfo(@PathVariable("inviteId") Long inviteId) {
        return AjaxResult.success(inviteService.selectInviteById(inviteId));
    }

    /**
     * 新增用户邀请
     */
    @PreAuthorize("@ss.hasPermi('user:invite:add')")
    @Log(title = "用户邀请", businessType = BusinessTypeEnum.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Invite invite) {
        return WebKit.toAjax(inviteService.insertInvite(invite));
    }

    /**
     * 修改用户邀请
     */
    @PreAuthorize("@ss.hasPermi('user:invite:edit')")
    @Log(title = "用户邀请", businessType = BusinessTypeEnum.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Invite invite) {
        return WebKit.toAjax(inviteService.updateInvite(invite));
    }

    /**
     * 删除用户邀请
     */
    @PreAuthorize("@ss.hasPermi('user:invite:remove')")
    @Log(title = "用户邀请", businessType = BusinessTypeEnum.DELETE)
	@DeleteMapping("/{inviteIds}")
    public AjaxResult remove(@PathVariable Long[] inviteIds) {
        return WebKit.toAjax(inviteService.deleteInviteByIds(inviteIds));
    }
}
